﻿
@{
    ViewBag.Title = "留样管理";
}

<div class="row col-md-12 ml-0" style="min-height:5vh;">
    <strong class="font-rfs" style="margin-right: 2rem;padding-top: 0.4rem;">留样管理</strong>
</div>
<div class="row col-md-12 ml-0" style="min-height:90vh;">
    <div class="table-responsive-sm shadow p-0 bg-white rounded col-md-12" style="min-height:90vh;">
        <div class="row col-md-12 tab-content" style="padding-left: 0;padding-right: 0px;right: -15px;height: 3vh;">
            <ul class="nav col-md-12" style="padding-right: 0;margin-bottom: 1px;min-height:3vh;height: 3vh;">
                <li id="li-tabRecipient" class="tabButton col-md-1 tab-first-active font-rfs" style="text-align:center;padding-left: 1px;padding-right: 1px;" data-active="true">
                    <a id="a-tabRecipient" href="#tabRecipient" data-toggle="tab" class="text-decoration-none" style="display: inline-block;width:100%;">接收留样</a>
                </li>
                <li id="li-tabDispose" class="tabButton col-md-1 tab-other-noactive font-rfs" style="text-align:center;padding-left: 1px;padding-right: 1px;" data-active="false">
                    <a id="a-tabDispose" href="#tabDispose" data-toggle="tab" class="text-decoration-none" style="display: inline-block;width:100%;">处置留样</a>
                </li>
                <li class="col-md-10 tab-Notactive" style="text-align: center;"><a href="" data-toggle="tab"></a></li>
            </ul>
        </div>
        <div class="row col-md-12 tab-content tab-body" style="padding-right: 0px;right: -15px;padding-left: 0px;top: -2px;min-height: 87vh;">
            <div class="col-md-12 ml-0 mr-0 tab-pane active" id="tabRecipient" style="padding-left: 0px;padding-right: 0px; ">
                <div class="row col-md-12" style="margin-bottom: 3px;min-height:3vh;">
                    <select id="RetentionSampleManage-selectRecipient" class="form-control font-rfs border-radius-noradius custom-headtoolbar-select" style="width:10%;"></select>
                    <button id="RetentionSampleManage-Recipient" class="btn btn-rfs" style="margin-left: 3px;"><i class="bi-box-arrow-in-right" style="color:#007bff"></i> 接收</button>
                </div>
                <div class="table-responsive-sm p-0 bg-white rounded col-md-12 pre-scrollable">
                    <table id="RetentionSampleManage-tabRecipient" class="table table-striped table-bordered table-sm table-hover">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th></th>
                                <th>样品ID</th>
                                <th>样品编号</th>
                                <th>批次号</th>
                                <th>名称</th>
                                <th>类型</th>
                                <th>分类</th>
                                <th>实验室</th>
                                <th>工作组</th>
                                <th>记录时间</th>
                                <th>接收人</th>
                                <th>接收时间</th>
                                <th>保存至</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
            <div class="col-md-12 ml-0 mr-0 tab-pane" id="tabDispose" style="padding-left: 0px;padding-right: 0px; ">
                <div class="row col-md-12" style="margin-bottom: 3px;min-height:3vh;">
                    <select id="RetentionSampleManage-selectDispose" class="form-control font-rfs border-radius-noradius custom-headtoolbar-select" style="width:10%;"></select>
                    <button id="RetentionSampleManage-use" class="btn btn-rfs"><i class="bi-check2-square" style="color:forestgreen"></i> 领用</button>
                    <button id="RetentionSampleManage-useReview" class="btn btn-rfs"><i class="bi-person-check-fill" style="color:red"></i> 领用审核</button>
                    <button id="RetentionSampleManage-Dispose" class="btn btn-rfs" style="margin-left: 3px;"><i class="bi-box-arrow-right" style="color:#007bff"></i> 处置</button>
                    @* <button id="RetentionSampleManage-disReview" class="btn btn-rfs"><i class="bi-person-check-fill" style="color:red"></i> 处置审核</button> *@
                </div>
                <div class="table-responsive-sm p-0 bg-white rounded col-md-12 pre-scrollable" style="min-height:60vh;height:60vh;">
                    <table id="RetentionSampleManage-tabDispose" class="table table-striped table-bordered table-sm table-hover"></table>
                </div>
                <div class="row col-md-12 ml-0 mr-0 " style="padding-left: 0px;padding-right: 0px;min-height:20vh;">
                    <div class="table-responsive-sm p-0 bg-white rounded col-md-8 pre-scrollable" style="height:18vh;">
                        <table id="RetentionSampleManage-tabRetentionUse" class="table table-striped table-bordered table-sm table-hover"></table>
                    </div>
                    <div class="table-responsive-sm p-0 bg-white rounded col-md-4 pre-scrollable" style="height:18vh;">
                        <table id="RetentionSampleManage-tabApproval" class="table table-striped table-bordered table-sm table-hover"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal" id="RetentionSampleManage-Recipient-Modal" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class='modal-header'>
                <p id="RecipientModalTitle" class="pt-3 pl-3 font-rfs"></p>
                <a data-dismiss="modal" class="modal-close">&times;</a>
            </div>
            <div class="modal-body">
                <div class="input-group">
                    <div class="col-3 pr-0">
                        <span class="input-group-text font-rfs border-radius-noright noRightBorder">包装数量</span>
                    </div>
                    <div class="col-9 pl-0 input-group">
                        <input id="RetentionSampleManage-Recipient-ContainerNumber" class="form-control font-rfs border-radius-noleft" style="width:30%" placeholder="整数" maxlength="2" onkeyup="value=value.replace(/[^\d]/g,'')" />
                        <span class="input-group-text font-rfs border-radius-noradius noRightBorder noLeftBorder" style="width:30%">包装类型</span>
                        <div class="input-group" style="width:40%">
                            <select id="RetentionSampleManage-Recipient-Select-Container" class="form-control font-rfs border-radius-noleft" style="width:40%"></select>
                            <div class="col-11 pl-0 input-group position-absolute float-left">
                                <input id="RetentionSampleManage-Recipient-Input-Container" class="form-control font-rfs border-radius-noleft noRightBorder" style="width:100%" placeholder="可输入" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="input-group">
                    <div class="col-3 pr-0">
                        <span class="input-group-text font-rfs border-radius-noright noRightBorder">每包数量</span>
                    </div>
                    <div class="col-9 pl-0 input-group">
                        <input id="RetentionSampleManage-Recipient-Quantity" class="form-control font-rfs border-radius-noleft" style="width:30%" />
                        <span class="input-group-text font-rfs border-radius-noradius noRightBorder noLeftBorder" style="width:30%">数量单位</span>
                        <div class="input-group" style="width:40%">
                            <select id="RetentionSampleManage-Recipient-Select-Unit" class="form-control font-rfs border-radius-noleft" style="width:40%"></select>
                            <div class="col-11 pl-0 input-group position-absolute float-left">
                                <input id="RetentionSampleManage-Recipient-Input-Unit" class="form-control font-rfs border-radius-noleft noRightBorder" style="width:100%" placeholder="可输入" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="input-group">
                    <div class="col-3 pr-0">
                        <span class="input-group-text font-rfs border-radius-noright noRightBorder">保存至</span>
                    </div>
                    <div class="col-9 pl-0 input-group">
                        <input id="RetentionSampleManage-Recipient-KeepTo" class="form-control font-rfs border-radius-noleft" placeholder="可选" />
                    </div>
                </div>
                <div class="input-group">
                    <div class="col-3 pr-0">
                        <span class="input-group-text font-rfs border-radius-noright noRightBorder">到期提醒</span>
                    </div>
                    <div class="col-9 pl-0">
                        <input id="RetentionSampleManage-Recipient-Remind" class="form-control font-rfs border-radius-noleft" placeholder="可选" />
                    </div>
                </div>
                <div class="input-group">
                    <div class="col-3 pr-0">
                        <span class="input-group-text font-rfs border-radius-noright noRightBorder">存储位置</span>
                    </div>
                    <div class="col-9 pl-0 input-group">
                        <select id="Recipient-Modal-Position" class="form-control font-rfs border-radius-noleft" style="width:90%"></select>
                    </div>
                </div>
                <div class="input-group">
                    <div class="col-3 pr-0">
                        <span class="input-group-text font-rfs border-radius-noright noRightBorder">存储条件</span>
                    </div>
                    <div class="col-9 pl-0 input-group">
                        <select id="RetentionSampleManage-Recipient-StorageConditions" class="form-control font-rfs border-radius-noleft" style="width:90%"></select>
                    </div>
                </div>
                <div class="input-group">
                    <div class="col-3 pr-0">
                        <span class="input-group-text font-rfs border-radius-noright noRightBorder">接收备注</span>
                    </div>
                    <div class="col-9 pl-0">
                        <input id="Recipient-Modal-Note" class="form-control font-rfs border-radius-noleft" placeholder="可不填" />
                    </div>
                </div>
                <div class="text-right">
                    <button id="Recipient-Modal-confirm" class="btn btn-primary font-rfs">确定</button>
                    <button id="Recipient-Modal-cancel" type="button" class="btn btn-info font-rfs">取消</button>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal" id="RetentionSampleManage-Modal" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class='modal-header'>
                <p id="RetentionSampleManage-Modal-Title" class="pt-3 pl-3 font-rfs"></p>
                <a data-dismiss="modal" class="modal-close">&times;</a>
            </div>
            <div class="modal-body">
                <div id="RetentionSampleManage-Modal-Embed"></div>
            </div>
        </div>
    </div>
</div>

@section Scripts {
    <script>
        var Ids = null;
        $(document).ready(function () {
            LoadRetention(null);
            LoadContainer();
            LoadUnit();
            GetLocationList('Recipient-Modal-Position', '留样');

            $.post("GetRetentionSampleBatch", {
                //Type: type
            }, function (data) {
                $('#RetentionSampleManage-selectRecipient').empty();
                for (var i = 0; i < data.length; i++) {
                    $('#RetentionSampleManage-selectRecipient').append(new Option(data[i].batchId));
                }
                $('#RetentionSampleManage-selectRecipient').prepend(new Option(""));
                $('#RetentionSampleManage-selectRecipient').val("");
            });

            $.post("GetDisposeSampleBatch", {
                //Type: type
            }, function (data) {
                $('#RetentionSampleManage-selectDispose').empty();
                for (var i = 0; i < data.length; i++) {
                    $('#RetentionSampleManage-selectDispose').append(new Option(data[i].batchId));
                }
                $('#RetentionSampleManage-selectDispose').prepend(new Option(""));
                $('#RetentionSampleManage-selectDispose').val("");
            });
        });

        function LoadContainer() {
            $.post("GetRetentionConfigContainer", {
            }, function (data) {
                for (var i = 0; i < data.length; i++) {
                    $("#RetentionSampleManage-Recipient-Select-Container").append(new Option(data[i].container));
                }
                $("#RetentionSampleManage-Recipient-Select-Container").prepend(new Option("", ""));
                $("#RetentionSampleManage-Recipient-Select-Container").val("");
            });
        }

        function LoadUnit() {
            $.post("GetRetentionConfigUnit", {
            }, function (data) {
                for (var i = 0; i < data.length; i++) {
                    $("#RetentionSampleManage-Recipient-Select-Unit").append(new Option(data[i].unit));
                }
                $("#RetentionSampleManage-Recipient-Select-Unit").prepend(new Option("", ""));
                $("#RetentionSampleManage-Recipient-Select-Unit").val("");
            });
        }

        function LoadRetention(batchId) {
            var columns = [{ field: "id", visible: false }, { field: "selectItem", width: "5%", align: "center", checkbox: true },
            { field: "sampleId" }, { field: "sampleNumber" }, { field: "batchId" }, { field: "name" }, { field: "classification" }, { field: "genricClass" },
            { field: "site" }, { field: "group" }, { field: "registrationTime", formatter: SetTime }, { field: "recipientName" },
            { field: "receptionTime", formatter: SetTime }, { field: "keepTo",formatter: SetDate }];

            $('#RetentionSampleManage-tabRecipient').bootstrapTable('destroy');
            $('#RetentionSampleManage-tabRecipient').bootstrapTable({
                method: 'post',
                url: "GetRetentionSample",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        batchId: batchId,
                        limit: params.limit, // 每页显示多少条记录
                        offset: params.offset // 偏移量
                    };
                    return data;
                },
                queryParamsType: "limit", // 服务器端分页，这个参数必需是“limit”
                dataField: "rows",

                uniqueId: "id",          // 设置主键
                sidePagination: "server", // 服务器端分页，这个参数必需设置
                pagination: true,  // 显示分页条,设为true，启用了分页功能
                pageNumber: 1,
                pageSize: 20,   // 默认页大小
                pageList: [20, 30, 50, 100],  // 控制每页数目
                locale: "zh-CN",
                columns: columns,

                selectItemName: "selectItem", // 指定选择行ID
                clickToSelect: true, // 相应单击，自动选中此行
                checkboxHeader: true, // 标题行显示全选按钮
                silent: true,
                onClickRow: function (row, $element, field) {
                },
                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $('#RetentionSampleManage-tabRecipient').bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {
                    SetBootstrapStyle();
                },
                formatShowingRows: function (pageFrom, pageTo, totalRows) {
                    return "正在显示第" + pageFrom + "到第" + pageTo + "条记录，总共" + totalRows + "条记录 ";
                },
                formatRecordsPerPage: function (pageNumber) {
                    return " 每页显示" + pageNumber + '条记录';
                }
            });
        }

        function SetTime(value, row, index) {
            return value == null ? '' : value.replace('T', ' ');
        }

        function SetDate(value, row, index) {
            return value == null ? '' : value.replace('T', ' ').split(' ')[0];
        }

        function LoadDispose(batchId) {
            var columns = [{ field: "id", visible: false }, { field: "selectItem", width: "5%", align: "center", checkbox: true },
            { field: "sampleId", title: "样品ID" }, { field: "sampleNumber", title: "样品编号" }, { field: "batchId", title: "批次号" },
            { field: "name", title: "名称" }, { field: "classification", title: "类型" }, { field: "genricClass", title: "分类" },
            { field: "container", title: "包装" }, { field: "containerNumber", title: "包装数" },{ field: "quantity", title: "总量" }, { field: "unit", title: "单位" },
            { field: "recipientName", title: "接收人" }, { field: "receptionTime", title: "接收时间", formatter: SetTime },
            { field: "keepTo", title: "保存至", formatter: SetDate }, { field: "remind", title: "提醒" }, { field: "note", title: "接收备注" }, { field: "position", title: "存储位置" },
            { field: "disApproval", title: "处审", width: "5%", align: "center", formatter: SetdisApproval },
            { field: "useApproval", title: "领审", width: "5%", align: "center", formatter: SetuseApproval }];

            $('#RetentionSampleManage-tabDispose').bootstrapTable('destroy');
            $('#RetentionSampleManage-tabDispose').bootstrapTable({
                method: 'post',
                url: "GetDisposeSample",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        batchId: batchId,
                        limit: params.limit, // 每页显示多少条记录
                        offset: params.offset // 偏移量
                    };
                    return data;
                },
                queryParamsType: "limit", // 服务器端分页，这个参数必需是“limit”
                dataField: "rows",

                uniqueId: "id",          // 设置主键
                sidePagination: "server", // 服务器端分页，这个参数必需设置
                pagination: true,  // 显示分页条,设为true，启用了分页功能
                pageNumber: 1,
                pageSize: 20,   // 默认页大小
                pageList: [20, 50, 100, 500],  // 控制每页数目
                locale: "zh-CN",
                columns: columns,

                selectItemName: "selectItem", // 指定选择行ID
                clickToSelect: true, // 相应单击，自动选中此行
                checkboxHeader: true, // 标题行显示全选按钮
                silent: true,
                onClickRow: function (row, $element, field) {
                    LoadRetentionUse(row.id);
                    $('#RetentionSampleManage-tabApproval').bootstrapTable('destroy');
                },
                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $('#RetentionSampleManage-tabDispose').bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {
                    SetBootstrapStyle();
                },
                formatShowingRows: function (pageFrom, pageTo, totalRows) {
                    return "正在显示第" + pageFrom + "到第" + pageTo + "条记录，总共" + totalRows + "条记录 ";
                },
                formatRecordsPerPage: function (pageNumber) {
                    return " 每页显示" + pageNumber + '条记录';
                }
            });
        }

        function SetdisApproval(value, row, index) {
            var strHtml = "";
            if (row.disApproval) {
                strHtml = "<input type='checkbox' checked onclick='UpdateDisApproval(this,event)'/>";
            } else {
                strHtml = "<input type='checkbox' onclick='UpdateDisApproval(this,event)'/>";
            }
            return strHtml;
        }

        function SetuseApproval(value, row, index) {
            var strHtml = "";
            if (row.useApproval) {
                strHtml = "<input type='checkbox' checked onclick='UpdateUseApproval(this,event)'/>";
            } else {
                strHtml = "<input type='checkbox' onclick='UpdateUseApproval(this,event)'/>";
            }
            return strHtml;
        }

        function UpdateDisApproval(obj) {
            var rowid = $(obj).parent().parent().attr('data-uniqueid');

            $.post("UpdateRetentionDisApproval", {
                RetentionSampleId: rowid
            }, function (data) {
                if (data.indexOf("成功") < 0) {
                    alert(data);
                }
            });
            event.stopPropagation();
        }

        function UpdateUseApproval(obj) {
            var rowid = $(obj).parent().parent().attr('data-uniqueid');

            $.post("UpdateRetentionUseApproval", {
                RetentionSampleId: rowid
            }, function (data) {
                if (data.indexOf("成功") < 0) {
                    alert(data);
                }
            });
            event.stopPropagation();
        }

        function LoadRetentionUse(retentionSampleId) {
            var columns = [{ field: "id", visible: false },
            { field: "containerNumber", title: "包装数" }, { field: "quantity", title: "领用数" }, { field: "unit", title: "单位" },
            { field: "userName", title: "领用人" }, { field: "useDateTime", title: "领用时间", formatter: SetTime }, { field: "note", title: "备注" }];

            $('#RetentionSampleManage-tabRetentionUse').bootstrapTable('destroy');
            $('#RetentionSampleManage-tabRetentionUse').bootstrapTable({
                method: 'post',
                url: "GetRetentionUses",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        RetentionSampleId: retentionSampleId
                    };
                    return data;
                },
                dataField: "rows",
                uniqueId: "id",          // 设置主键
                locale: "zh-CN",
                columns: columns,
                silent: true,
                onClickRow: function (row, $element, field) {
                    $("#RetentionSampleManage-tabRetentionUse").find("tbody").find("tr").each(function () {
                        $(this).removeClass('changeblueColor');
                    });
                    $element.addClass("changeblueColor");
                   LoadUseWorkFlow(row.id);
                },
                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $('#RetentionSampleManage-tabRetentionUse').bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {
                    SetBootstrapStyle();
                },
                formatShowingRows: function (pageFrom, pageTo, totalRows) {
                    return "正在显示第" + pageFrom + "到第" + pageTo + "条记录，总共" + totalRows + "条记录 ";
                },
                formatRecordsPerPage: function (pageNumber) {
                    return " 每页显示" + pageNumber + '条记录';
                }
            });
        }

        function LoadUseWorkFlow(useId) {
            var columns = [{ field: "id", visible: false },
            { field: "stepName", title: "流程步骤" }, { field: "status", title: "步骤状态" }, { field: "recordTime", title: "进入时间", formatter: SetTime },
            { field: "currentHandlerType", title: "处理人" }, { field: "handlingTime", title: "处理时间", formatter: SetTime },
            { field: "suggestion", title: "处理意见" }];

            $('#RetentionSampleManage-tabApproval').bootstrapTable('destroy');
            $('#RetentionSampleManage-tabApproval').bootstrapTable({
                method: 'post',
                url: "GetRetentionUseApprovalRecords",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        RetentionUseId: useId
                    };
                    return data;
                },
                dataField: "rows",
                uniqueId: "id",          // 设置主键
                locale: "zh-CN",
                columns: columns,
                silent: true,
                onClickRow: function (row, $element, field) {
                },
                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {
                    $("#RetentionSampleManage-useReview").attr("disabled", true);
                    $('.fixed-table-toolbar').css("height", "0px"); /* 隐藏表格上的工具栏 */
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $('#RetentionSampleManage-tabApproval').bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {
                    $("#RetentionSampleManage-useReview").removeAttr("disabled");
                    SetBootstrapStyle();
                },
                formatShowingRows: function (pageFrom, pageTo, totalRows) {
                    return "正在显示第" + pageFrom + "到第" + pageTo + "条记录，总共" + totalRows + "条记录 ";
                },
                formatRecordsPerPage: function (pageNumber) {
                    return " 每页显示" + pageNumber + '条记录';
                }
            });
        }

        $("#RetentionSampleManage-selectRecipient").change(function () {
            LoadRetention($('#RetentionSampleManage-selectRecipient').val());
        });

        $("#RetentionSampleManage-selectDispose").change(function () {
            $('#RetentionSampleManage-tabRetentionUse').bootstrapTable('destroy');
            $('#RetentionSampleManage-tabApproval').bootstrapTable('destroy');
            LoadDispose($('#RetentionSampleManage-selectDispose').val());
        });

        $("#RetentionSampleManage-Recipient").click(function () {
            Ids = GetSelectItems('RetentionSampleManage-tabRecipient');
            if (Ids == null) {
                alert("请先选择要接收的样品！");
                return;
            }

            $.post("GetRetentionSampleById", {
                RetentionSampleId: Ids.split(',')[0]
            }, function (datas) {
                if (datas) {
                    $("#RetentionSampleManage-Recipient-ContainerNumber").val(datas.containerNumber);
                    $("#RetentionSampleManage-Recipient-Input-Container").val(datas.container);
                    $("#RetentionSampleManage-Recipient-Quantity").val(datas.quantity);
                    $("#RetentionSampleManage-Recipient-Input-Unit").val(datas.unit);
                    var keep = datas.keepTo;
                    $("#RetentionSampleManage-Recipient-KeepTo").val(keep.split('T')[0]);
                    $("#RetentionSampleManage-Recipient-Remind").val(datas.remind);
                    $("#Recipient-Modal-Position").val(datas.position);
                }
            });

            $("#RecipientModalTitle").text("接收留样");

            $("#RetentionSampleManage-Recipient-Modal").modal({
                backdrop: 'static',
                keyboard: false
            });
        });

        $("#RetentionSampleManage-Dispose").click(function () {
            Ids = GetSelectItems('RetentionSampleManage-tabDispose');
            if (Ids == null) {
                alert("请先选择要处置的样品！");
                return;
            }

            $("#RetentionSampleManage-Modal-Title").text("留样处置");
            $("#RetentionSampleManage-Modal").modal({
                backdrop: 'static',
                keyboard: false
            });

            $.post("DisRetentionSample", {
                RetentionSampleIds: Ids,
                ModalID: "RetentionSampleManage-Modal"
            }, function (datas) {
                $("#RetentionSampleManage-Modal-Embed").html(datas);
            });
        });

        $("#Recipient-Modal-confirm").click(function () {
            var jsonStr = {};
            jsonStr["ContainerNumber"] = $.trim($("#RetentionSampleManage-Recipient-ContainerNumber").val());
            jsonStr["Container"] = $.trim($("#RetentionSampleManage-Recipient-Input-Container").val());
            jsonStr["Quantity"] = $.trim($("#RetentionSampleManage-Recipient-Quantity").val());
            jsonStr["Unit"] = $.trim($("#RetentionSampleManage-Recipient-Input-Unit").val());
            jsonStr["Remind"] = $.trim($("#RetentionSampleManage-Recipient-Remind").val());
            jsonStr["Position"] = $("#Recipient-Modal-Position").find("option:selected").text();
            // jsonStr["StorageConditions"] = $("#RetentionSampleManage-Recipient-StorageConditions").val();

            $.post("RecipientSample", {
                Ids: Ids,
                Note: $.trim($("#Recipient-Modal-Note").val()),
                jsonRetentionConfig: JSON.stringify(jsonStr),
                KeepTo: $.trim($("#RetentionSampleManage-Recipient-KeepTo").val())
            }, function (data) {
                if (data.indexOf("成功") >= 0) {
                    LoadRetention();
                    $("#Recipient-Modal-cancel").click();
                } else {
                    alert(data);
                }                
            });
        });

        $("#Recipient-Modal-cancel").click(function () {
            Ids = null;
            $("#RetentionSampleManage-Recipient-Modal").modal('hide');
        });

        $("#RetentionSampleManage-use").click(function () {
            var ids = GetSelectItems('RetentionSampleManage-tabDispose');
            if (ids == null) {
                alert("请先选择对应的留样！");
                return;
            }

            $("#RetentionSampleManage-Modal-Title").text("留样领用");
            $("#RetentionSampleManage-Modal").modal({
                backdrop: 'static',
                keyboard: false
            });

            $.post("AddRetentionUse", {
                RetentionSampleIds: ids,
                ModalID: "RetentionSampleManage-Modal"
            }, function (datas) {
                $("#RetentionSampleManage-Modal-Embed").html(datas);
            });
        });

        $("#RetentionSampleManage-useReview").click(function () {
            var ruid = GetSelectIdByColor('RetentionSampleManage-tabRetentionUse');
            if (ruid.length == 0) {
                alert("请先选择留样领用记录！");
                return;
            }

            $("#RetentionSampleManage-Modal-Title").text("留样领用审批");

            $("#RetentionSampleManage-Modal").modal({
                backdrop: 'static',
                keyboard: false
            });

            $.post("\\WorkFlow\\ExamineAndApprove", {
                DomainName: "RetentionUse",
                DomainId: ruid,
                ModalID: "RetentionSampleManage-Modal"
            }, function (data) {
                $("#RetentionSampleManage-Modal-Embed").html(data);
            });
        });

        $("#li-tabRecipient").hover(
            function () {
                if ($(this).attr("class").indexOf('tab-first-active') > 0) {
                    $(this).addClass('tab-enter-mouse');
                }
                if ($(this).attr("class").indexOf('tab-first-noactive') > 0) {
                    $(this).removeClass('tab-first-noactive');
                    $(this).addClass('tab-first-noactive-mouse');
                }
            },
            function () {
                $(this).removeClass('tab-enter-mouse');
                $(this).removeClass('tab-first-noactive-mouse');

                if ($(this).attr("data-active") == 'true') {
                    $(this).addClass('tab-first-active');
                }
                if ($(this).attr("data-active") == 'false') {
                    $(this).addClass('tab-first-noactive');
                }
            });

        $("#a-tabRecipient").click(function () {
            if ($("#li-tabDispose").attr("class").indexOf('tab-other-active') > 0) {
                $("#li-tabDispose").removeClass('tab-other-active');
                $("#li-tabDispose").addClass('tab-other-noactive');
            }

            $("#li-tabRecipient").attr("data-active", true);
            $("#li-tabDispose").attr("data-active", false);
        });

        $("#li-tabDispose").hover(
            function () {
                if ($(this).attr("class").indexOf('tab-other-active') > 0) {
                    $(this).addClass('tab-enter-mouse');
                }
                if ($(this).attr("class").indexOf('tab-other-noactive') > 0) {
                    $(this).removeClass('tab-other-noactive');
                    $(this).addClass('tab-other-noactive-mouse');
                }
            },
            function () {
                $(this).removeClass('tab-enter-mouse');
                $(this).removeClass('tab-other-noactive-mouse');

                if ($(this).attr("data-active") == 'true') {
                    $(this).addClass('tab-other-active');
                }
                if ($(this).attr("data-active") == 'false') {
                    $(this).addClass('tab-other-noactive');
                }
            });

        $("#a-tabDispose").click(function () {
            if ($("#li-tabRecipient").attr("class").indexOf('tab-first-active') > 0) {
                $("#li-tabRecipient").removeClass('tab-first-active');
                $("#li-tabRecipient").addClass('tab-first-noactive');
            }

            $("#li-tabDispose").attr("data-active", true);
            $("#li-tabRecipient").attr("data-active", false);

            LoadDispose(null);
        });

    </script>
}
